package com.zxy.controller;


import com.zxy.model.Vendor;

import com.zxy.model.VendorQuery;
import com.zxy.service.VendorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/vendor")
//restFul
public class VendorController {

    @Autowired
    private VendorService vendorService;
    @GetMapping//http://a.com?a=1&b=2  //http://a.com?id=1&name=张三
    public List<Vendor>  select(VendorQuery query){
      return  vendorService.select(query);
    }

    @PostMapping//通过 RequestBody 请求体 传过来的json数据 给我们自动转为Category 这个对象
    public Integer insert(@RequestBody Vendor  vendor){
        return vendorService.insert(vendor);
    }

    @PutMapping//通过 RequestBody 请求体 传过来的json数据 给我们自动转为Category 这个对象
    public Integer update(@RequestBody Vendor  vendor){

        return vendorService.update(vendor);
    }

}
